import java.io.* ;
import java.net.* ;

public class SocketWriteThread extends Thread {

   Socket sk = null ;
   
   public SocketWriteThread ( Socket s ) { sk = s; } 

   public void run() {
	try {
		OutputStreamWriter out = new OutputStreamWriter ( sk.getOutputStream()) ;
		String s;
		for ( int i = 0; i < 10; i ++ ) { 
			s = (int) (Math.random() * 1000) + "\n";
			out.write(s, 0, s.length());
			out.flush();
			Thread.yield() ;  // give up CPU.
			// sleep(500);
		}
		out.write("END\n"); // tell other end that data is over.
		out.flush() ;
 	} catch( IOException e ) { e.printStackTrace() ; }
	  // catch (InterruptedException e) {}
   }
}
